import requests
import json
from jsonpath import jsonpath

headers = {
    'user-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
    'referer': 'https://save.sorftime.com/?browser=1&site=01&token=VnIxdzBDR0E5SmhlY21iRFF5NUYrQT09&nodeId=baby-products&v=1.1.6.3&topnode=YmFieS1wcm9kdWN0cw%3D%3D&lang=zh-CN&drawer=false',
    'origin': 'https://save.sorftime.com',
    'accept': 'application/json, text/plain, */*',
    'authority': 'save.sorftime.com',
    'authorization': 'BasicAuth VnIxdzBDR0E5SmhlY21iRFF5NUYrQT09'
}

requset_data= {"ProductId":"",
               "screenProductIds":"",
               "Range":0,
               "Month":-3,
               "BrandRecord":-1,
               "BeginDate":"",
               "EndDate":"",
               "End":20,
               "PageRange":1,
               "PageSize":100,
               "BeginPageRange":"",
               "EndPageRange":"",
               "VariantMonth":0,
               "NodeId":"baby-products",
               "Site":"01",
               "Topnode":"YmFieS1wcm9kdWN0cw===",
               "SearchAsinStr":"",
               "Browser":"1"}
r = requests.post('https://save.sorftime.com/api/FlowCircle/InitBrandCharts?site=01&nodeId=baby-products',json = requset_data,headers=headers)
# amazon_top = r.json()
# print (amazon_top)
amz_top = r.json()
# print (amz_top)
amz_select = jsonpath(amz_top, '$.Data..Data')

print (amz_select)
print ("此次解析数据为",len(amz_select),"条")